<!DOCTYPE HTML>
<html>
<head>

    <title>JSite 表单设计器 jsite.org.cn</title>
    <meta name="keyword" content="表单设计器" />
    <meta name="description" content="WEB表单设计器扩展" />

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="author" content="jsite.org.cn" />
    <link href="css/bootstrap/css/bootstrap.css?2023" rel="stylesheet" type="text/css"/>
    <!--[if lte IE 6]>
    <link rel="stylesheet" type="text/css" href="css/bootstrap/css/bootstrap-ie6.css?2023" />
    <![endif]-->
    <!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="css/bootstrap/css/ie.css?2023" />
    <![endif]-->
    <link href="css/site.css?2023" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="../jquery-toastr/toastr.min.css" />

</head>
<body>
<div class="container" style="width:1500px;">
    <div class="row" style="padding: 10px;margin-left: 20px;">
        <button type="button" onclick="leipiFormDesign.exec('text');" class="btn btn-info">文本框</button>
        <button type="button" onclick="leipiFormDesign.exec('textarea');" class="btn btn-info">多行文本</button>
        <button type="button" onclick="leipiFormDesign.exec('select');" class="btn btn-info">下拉菜单</button>
        <button type="button" onclick="leipiFormDesign.exec('radios');" class="btn btn-info">单选框</button>
        <button type="button" onclick="leipiFormDesign.exec('checkboxs');" class="btn btn-info">复选框</button>
        <button type="button" onclick="leipiFormDesign.exec('textdate');" class="btn btn-info">日期框</button>
        <button type="button" onclick="leipiFormDesign.exec('numcount');" class="btn btn-info">合计框</button>
        <button type="button" onclick="leipiFormDesign.exec('selectperson');" class="btn btn-info">人员下拉菜单</button>
        <button type="button" onclick="leipiFormDesign.exec('selectdept');" class="btn btn-info">部门下拉菜单</button>

    </div>
    <div class="row" style="padding: 10px;margin-left: 20px;">
        <button type="button" onclick="leipiFormDesign.exec('file_upload');" class="btn btn-info">文件上传</button>
        <button type="button" onclick="leipiFormDesign.exec('excelurl');" class="btn btn-info">ExcelURL</button>
        <button type="button" onclick="leipiFormDesign.exec('excel_download');" class="btn btn-info">Excel下载</button>
        <button type="button" onclick="leipiFormDesign.exec('excel_preview');" class="btn btn-info">Excel预览</button>
        <button type="button" onclick="leipiFormDesign.exec('excel_print');" class="btn btn-info">Excel打印</button>
        <button type="button" onclick="leipiFormDesign.exec('task_assignee');" class="btn btn-info">节点处理人</button>
        <button type="button" onclick="leipiFormDesign.exec('task_assignees');" class="btn btn-info">节点处理人(多选)</button>
        <button type="button" onclick="leipiFormDesign.exec('attachment');" class="btn btn-info">附件表</button>
    </div>
        <script id="myFormDesign" type="text/plain" style="width:100%;"> </script>
</div>

<script type="text/javascript" charset="utf-8" src="js/jquery-1.7.2.min.js?2023"></script>
<script src="../common/jsite.js"></script>
<script src="../jquery-toastr/toastr.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/ueditor/ueditor.config.js?2023"></script>
<script type="text/javascript" charset="utf-8" src="js/ueditor/ueditor.all.js?2023"></script>
<script type="text/javascript" charset="utf-8" src="js/ueditor/lang/zh-cn/zh-cn.js?2023"></script>
<script type="text/javascript" charset="utf-8" src="js/ueditor/formdesign/leipi.formdesign.v4.js?2023"></script>

<script type="text/javascript">
    var modelId = js.getUrlParam('modelId');
    var modelKey = js.getUrlParam('modelKey');
    var modelVersion = js.getUrlParam('modelVersion');


    var leipiEditor = UE.getEditor('myFormDesign', {
        //allowDivTransToP: false,//阻止转换div 为p
        toolleipi: true,//是否显示，设计器的 toolbars
        textarea: 'design_content',
        //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
        toolbars: [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|', 'fontfamily', 'fontsize', '|', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'link', 'unlink', '|', 'horizontal', 'spechars', 'wordimage', '|', 'inserttable', 'deletetable', 'mergecells', 'splittocells']],
        //focus时自动清空初始化时的内容
        //autoClearinitialContent:true,
        //关闭字数统计
        wordCount: false,
        //关闭elementPath
        elementPathEnabled: false,
        //默认的编辑区域高度
        initialFrameHeight: 450
        ///,iframeCssUrl:"css/bootstrap/css/bootstrap.css" //引入自身 css使编辑器兼容你网站css
        //更多其他参数，请参考ueditor.config.js中的配置项
    });

    var leipiFormDesign = {
        exec: function (method) {
            leipiEditor.execCommand(method);
        },
        /*type  =  save 保存设计 versions 保存版本  close关闭 */
        fnCheckForm: function (type) {
            if (leipiEditor.queryCommandState('source'))
                leipiEditor.execCommand('source');//切换到编辑模式才提交，否则有bug

            if (leipiEditor.hasContents()) {
                leipiEditor.sync();

                //获取表单设计器里的内容
                var formContent = leipiEditor.getContent();
                var data = {
                    'modelId': modelId,
                    'modelKey': modelKey,
                    'modelVersion': modelVersion,
                    'formContent': formContent
                };
                js.ajaxRequest("http://demo.jsite.org.cn/jsite/a/act/flowForm/save", data, function (data) {
                    js.showMessage(data.message);
                }, true);
            } else {
                js.showWarningMessage('表单内容不能为空！');
                $('#submitbtn').button('reset');
                return false;
            }
        }
    };

    js.ajaxRequest("http://demo.jsite.org.cn/jsite/a/act/flowForm/content", {
        modelId: modelId,
        modelKey: modelKey,
        modelVersion: modelVersion
    }, function (data) {
        if (data.data != undefined) {
            setTimeout(function () {
                leipiEditor.setContent(data.data.formContent, false);
            }, 1500);
        }
    }, true);

</script>
</body>
</html>